<?php
/**----------------------------------------------------------------------
 * Purpose： Bootstrap Class
 * 
 * CreateDate : 2014/08/19
 * Description：
 * 
 * @package		C-UNIT Class
 * @author	 	C-UNIT SQUARE Co.,Ltd. <info@c-unit.co.jp>
 * @copyright 	Copyright(c) 2014　C-UNIT SQUARE Co.,Ltd. All Rights Reserved.
 * @license		C-UNIT SQUARE Co.,Ltd.
 ------------------------------------------------------------------------*/
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	/**-------------------------------------------------------------------
	 * Init database
	 --------------------------------------------------------------------*/
	protected function _initDb()
	{
        $objDatabase = $this->getPluginResource('db')->getDbAdapter();
        Zend_Registry::set('db', $objDatabase);    
	}
	
	/**-------------------------------------------------------------------
	 * Init view
	 * @return object view
	 --------------------------------------------------------------------*/
	protected function _initView()
	{
		$objView = new CUnit_View_Smarty($this->getOption('smarty'));
		$objViewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
		$objViewRenderer->setViewSuffix('tpl');
		$objViewRenderer->setViewScriptPathSpec(":controller/:action.:suffix");
		$objViewRenderer->setView($objView);
		$this->bootstrap('layout');
		$objLayout = Zend_Layout::getMvcInstance();
		$objLayout->setLayoutPath(TEMPLATE_PATH)
			 ->setLayout('layout')
			 ->setViewSuffix('tpl');
		return $objView;
	}
}
